package com.visizen.wisdomclass.server.client;

import com.visizen.wisdomclass.server.model.WcCalendar;
import com.visizen.wisdomclass.server.model.WcCalendarExample;
import com.visizen.wisdomclass.server.model.dto.CalendarExt;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.Date;
import java.util.List;

public interface WcCalendarMapper {
    @Select("select * from wc_calendar where organization_id=#{classId} and calendar_date = #{calendarDate}")
    List<WcCalendar> selectEventListByClassIdAndDate(@Param("classId") Long classId,
                                                     @Param("calendarDate") Date date);

    @Select(" select *,count(*) as count from wc_calendar \n" +
            " where organization_id=#{classId} and\n" +
            "      calendar_date >= #{startDate} and calendar_date < #{endDate}\n" +
            " group by calendar_date\n" +
            " order by calendar_date asc;")
    @Results({
            @Result(property = "count", column = "count")
    })
    List<CalendarExt> selectEventCount(@Param("classId") Long classId,
                                       @Param("startDate") Date startDate,
                                       @Param("endDate") Date endDate);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_calendar
     *
     * @mbggenerated
     */
    @SelectProvider(type = WcCalendarSqlProvider.class, method = "countByExample")
    int countByExample(WcCalendarExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_calendar
     *
     * @mbggenerated
     */
    @DeleteProvider(type = WcCalendarSqlProvider.class, method = "deleteByExample")
    int deleteByExample(WcCalendarExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_calendar
     *
     * @mbggenerated
     */
    @Delete({"delete from wc_calendar",
            "where calendar_id = #{calendar_id,jdbcType=BIGINT}"})
    int deleteByPrimaryKey(Long calendar_id);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_calendar
     *
     * @mbggenerated
     */
    @Insert({
            "insert into wc_calendar (calendar_id, organization_id, ",
            "calendar_title, calendar_date, ",
            "createtime, calendar_content)",
            "values (#{calendar_id,jdbcType=BIGINT}, #{organization_id,jdbcType=BIGINT}, ",
            "#{calendar_title,jdbcType=VARCHAR}, #{calendar_date,jdbcType=DATE}, ",
            "#{createtime,jdbcType=TIMESTAMP}, #{calendar_content,jdbcType=LONGVARCHAR})"})
    int insert(WcCalendar record);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_calendar
     *
     * @mbggenerated
     */
    @InsertProvider(type = WcCalendarSqlProvider.class, method = "insertSelective")
    int insertSelective(WcCalendar record);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_calendar
     *
     * @mbggenerated
     */
    @SelectProvider(type = WcCalendarSqlProvider.class, method = "selectByExampleWithBLOBs")
    @Results({
            @Result(column = "calendar_id", property = "calendar_id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "organization_id", property = "organization_id", jdbcType = JdbcType.BIGINT),
            @Result(column = "calendar_title", property = "calendar_title", jdbcType = JdbcType.VARCHAR),
            @Result(column = "calendar_date", property = "calendar_date", jdbcType = JdbcType.DATE),
            @Result(column = "createtime", property = "createtime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "calendar_content", property = "calendar_content", jdbcType = JdbcType.LONGVARCHAR)})
    List<WcCalendar> selectByExampleWithBLOBs(WcCalendarExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_calendar
     *
     * @mbggenerated
     */
    @SelectProvider(type = WcCalendarSqlProvider.class, method = "selectByExample")
    @Results({
            @Result(column = "calendar_id", property = "calendar_id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "organization_id", property = "organization_id", jdbcType = JdbcType.BIGINT),
            @Result(column = "calendar_title", property = "calendar_title", jdbcType = JdbcType.VARCHAR),
            @Result(column = "calendar_date", property = "calendar_date", jdbcType = JdbcType.DATE),
            @Result(column = "createtime", property = "createtime", jdbcType = JdbcType.TIMESTAMP)})
    List<WcCalendar> selectByExample(WcCalendarExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_calendar
     *
     * @mbggenerated
     */
    @Select({
            "select",
            "calendar_id, organization_id, calendar_title, calendar_date, createtime, calendar_content",
            "from wc_calendar",
            "where calendar_id = #{calendar_id,jdbcType=BIGINT}"})
    @Results({
            @Result(column = "calendar_id", property = "calendar_id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "organization_id", property = "organization_id", jdbcType = JdbcType.BIGINT),
            @Result(column = "calendar_title", property = "calendar_title", jdbcType = JdbcType.VARCHAR),
            @Result(column = "calendar_date", property = "calendar_date", jdbcType = JdbcType.DATE),
            @Result(column = "createtime", property = "createtime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "calendar_content", property = "calendar_content", jdbcType = JdbcType.LONGVARCHAR)})
    WcCalendar selectByPrimaryKey(Long calendar_id);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_calendar
     *
     * @mbggenerated
     */
    @UpdateProvider(type = WcCalendarSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") WcCalendar record,
                                 @Param("example") WcCalendarExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_calendar
     *
     * @mbggenerated
     */
    @UpdateProvider(type = WcCalendarSqlProvider.class, method = "updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") WcCalendar record,
                                 @Param("example") WcCalendarExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_calendar
     *
     * @mbggenerated
     */
    @UpdateProvider(type = WcCalendarSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") WcCalendar record,
                        @Param("example") WcCalendarExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_calendar
     *
     * @mbggenerated
     */
    @UpdateProvider(type = WcCalendarSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(WcCalendar record);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_calendar
     *
     * @mbggenerated
     */
    @Update({"update wc_calendar",
            "set organization_id = #{organization_id,jdbcType=BIGINT},",
            "calendar_title = #{calendar_title,jdbcType=VARCHAR},",
            "calendar_date = #{calendar_date,jdbcType=DATE},",
            "createtime = #{createtime,jdbcType=TIMESTAMP},",
            "calendar_content = #{calendar_content,jdbcType=LONGVARCHAR}",
            "where calendar_id = #{calendar_id,jdbcType=BIGINT}"})
    int updateByPrimaryKeyWithBLOBs(WcCalendar record);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_calendar
     *
     * @mbggenerated
     */
    @Update({"update wc_calendar",
            "set organization_id = #{organization_id,jdbcType=BIGINT},",
            "calendar_title = #{calendar_title,jdbcType=VARCHAR},",
            "calendar_date = #{calendar_date,jdbcType=DATE},",
            "createtime = #{createtime,jdbcType=TIMESTAMP}",
            "where calendar_id = #{calendar_id,jdbcType=BIGINT}"})
    int updateByPrimaryKey(WcCalendar record);
}